package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.EngineerLevel;
import com.shrcl.engineerprocess.domain.proxy.EngineerLevelProxy;
import com.uniquesoft.uidl.validation.Validates;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("ENGINEERLEVEL_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "engineerlevel")
public class EngineerLevelImpl extends BaseModelObject implements EngineerLevel {
  public EngineerLevelImpl() {
    super();
  }
  
  private String levelId;
  
  public String getLevelId() {
    return this.levelId;
  }
  
  public EngineerLevel setLevelId(final String levelId) {
    this.levelId = levelId;
    return this;			
    
  }
  
  private String name;
  
  public String getName() {
    return this.name;
  }
  
  public EngineerLevel setName(final String name) {
    this.name = name;
    return this;			
    
  }
  
  public String getEntityName() {
    return this.name;
  }
  
  private Double forceCost;
  
  public Double getForceCost() {
    return this.forceCost;
  }
  
  public EngineerLevel setForceCost(final Double forceCost) {
    this.forceCost = forceCost;
    return this;			
    
  }
  
  private Double latestCost;
  
  public Double getLatestCost() {
    return this.latestCost;
  }
  
  public EngineerLevel setLatestCost(final Double latestCost) {
    this.latestCost = latestCost;
    return this;			
    
  }
  
  public void update(final Procedure1<? super EngineerLevel> updater) {
    updater.apply(this);
    this.checkValid();
  }
  
  public void checkValid() {
    boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(this.levelId);
    boolean _not = (!_isNullOrEmpty);
    Validates.Assert(_not, "\u7EA7\u522B\u7F16\u53F7\u4E0D\u80FD\u4E3A\u7A7A");
    boolean _isNullOrEmpty_1 = StringExtensions.isNullOrEmpty(this.name);
    boolean _not_1 = (!_isNullOrEmpty_1);
    Validates.Assert(_not_1, "\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A");
  }
  
  public static EngineerLevel create(final IObjectFactory objectFactory) {
    com.shrcl.engineerprocess.domain.EngineerLevel engineerLevel = new com.shrcl.engineerprocess.domain.impl.EngineerLevelImpl(
    );
    objectFactory.create(engineerLevel);
    return engineerLevel;			
    
  }
  
  public static EngineerLevel createEngineerLevelImpl(final IObjectFactory objectFactory, final Procedure1<EngineerLevel> init) {
    com.shrcl.engineerprocess.domain.EngineerLevel engineerLevel = new com.shrcl.engineerprocess.domain.impl.EngineerLevelImpl(
    );
    objectFactory.create(engineerLevel);
    init.apply(engineerLevel);
    
    return engineerLevel;			
    
  }
  
  public EngineerLevelProxy toProxy() {
    com.shrcl.engineerprocess.domain.proxy.EngineerLevelProxy proxy = new com.shrcl.engineerprocess.domain.proxy.EngineerLevelProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
